import request from '@/utils/request';

/**
 * 分页查询订舱代理
 */
export async function pageBookingAgents(params) {
  const res = await request.get('/order/bookingAgent/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询订舱代理列表
 */
export async function listBookingAgents(params) {
  const res = await request.get('/order/bookingAgent', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询订舱代理
 */
export async function getBookingAgent(id) {
  const res = await request.get('/order/bookingAgent/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加订舱代理
 */
export async function addBookingAgent(data) {
  const res = await request.post('/order/bookingAgent', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改订舱代理
 */
export async function updateBookingAgent(data) {
  const res = await request.put('/order/bookingAgent', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除订舱代理
 */
export async function removeBookingAgent(id) {
  const res = await request.delete('/order/bookingAgent/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 审核订舱代理
 */
export async function examBookingAgent(data) {
  const res = await request.post('/order/bookingAgent/examBookingAgent', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
